<?php
defined('_JEXEC') or die('Restricted access');

JHTML::_('behavior.tooltip');
?>
<form action="index.php" method="post" name="adminForm">
<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'Filter' ); ?>:
		<input type="text" name="search" id="search" value="<?php echo $this->search;?>" class="text_area" onchange="document.adminForm.submit();" />
		<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
		<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_catid').value='0';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
	</td>
	<td nowrap="nowrap">
		<?php
                        echo $this->campaigns;
		?>
	</td>
</tr>
</table>
<div id="editcell">
	<table class="adminlist">
	<thead>
		<tr>
			<th width="5">
				<?php echo JText::_( 'NUM' ); ?>
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->data ); ?>);" />
			</th>
			<th class="title">
				<?php echo JHTML::_('grid.sort',  'Email', 's.subscriber_email', $this->order_Dir, $this->order ); ?>
			</th>
			<th width="15%"  class="title">
				<?php echo JHTML::_('grid.sort',  'Name', 's.subscriber_name', $this->order_Dir, $this->order ); ?>
			</th>
			<th width="15%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',  'Campaign', 's.campaign', $this->order_Dir, $this->order ); ?>
			</th>
			<th width="15%"  class="title">
				<?php echo JHTML::_('grid.sort',  'Activated', 's.confirmed', $this->order_Dir, $this->order ); ?>
			</th>
			<th width="1%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',  'ID', 's.id', $this->order_Dir, $this->order ); ?>
			</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td colspan="9">
				<?php echo $this->pagination->getListFooter(); ?>
			</td>
		</tr>
	</tfoot>
	<tbody>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->data ); $i < $n; $i++)
	{
		$row = &$this->data[$i];

		$link 	= JRoute::_( 'index.php?option=com_letterman&view=subscriber&task=edit&cid[]='. $row->id );

		$checked 	= JHTML::_('grid.checkedout',   $row, $i );

		$ordering = ($this->order == 's.created_time');

		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<?php echo $this->pagination->getRowOffset( $i ); ?>
			</td>
			<td>
				<?php echo $checked; ?>
			</td>
			<td>
				<?php
				if (  JTable::isCheckedOut($this->user->get ('id'), $row->checked_out ) ) {
					echo $row->title;
				} else {
				?>
				<span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Newsletter' );?>::<?php echo $row->subscriber_email; ?>">
					<a href="">
						<?php echo $row->subscriber_email; ?></a></span>
				<?php
				}
				?>
			</td>
			<td align="center">
				<?php echo $row->subscriber_name ;?>
			</td>
                        <td align="center">
				<?php echo $row->campaign_name ;?>
			</td>
			<td align="center">
				<?php echo $row->activated;?>
			</td>
			<td align="center">
				<?php echo $row->id; ?>
			</td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</tbody>
	</table>
</div>

	<input type="hidden" name="option" value="com_letterman" />
        <input type="hidden" name="view" value="subscribers" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->order ; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->order_Dir ; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>